import os
import subprocess
import sys
import math
import random
import numpy as np

#2HDMC_dir = "/home/yancywww/Softare/bin/HiggsRelated/2HDMC-1.8.0_hbmodified"
HDMC_dir = "/home/yancywww/Software/bin/HiggsRelated/2HDMC-1.8.0_hbmodified"
scan_dir = "/home/yancywww/Softare/bin/HiggsRelated/2HDMC-1.8.0_hbmodified/python_scan"
data_file = "basic_scan.dat"
scan_file = "permit_points.dat"

mAu = 1000.0
mAd = 62.0

mhu = 124.9
mhd = 15.0

mCu = 200.0
mCd = 92.0

sbau = -0.05
sbad = -0.25

tanbu = 60.0
tanbd = 3.0


for i in range(1, 100000, 1):
######## input parameter 10000 ############
    mH = 125.0
    typ = 3
    mA   = random.uniform(0,1)*(mAu-mAd) + mAd
    mh   = random.uniform(0,1)*(mhu-mhd) + mhd
    mC   = random.uniform(0,1)*(mCu-mCd) + mCd
    sba  = random.uniform(0,1)*(sbau-sbad) + sbad
    tanb = random.uniform(0,1)*(tanbu-tanbd) + tanbd
    m12_2 = mh*mh*tanb/(1.0+tanb*tanb)
    m12_2 = mh*mh*tanb/(1.0+tanb*tanb)
    l6 = 0.0
    l7 = 0.0

######## run 2HDMC & HB & HS ##############

    os.chdir(HDMC_dir)
    subprocess.call(['./single_point', str(mh), str(mH), str(mA), str(mC), str(sba), str(tanb), str(l6), str(l7), str(m12_2), str(typ), str(data_file)])
    print("finished "+str(i)+" points...");

######## test vs experimental and theoretical constraints ######

#data = pd.read_csv(input_data_file, sep="\s+")
#data_theo_HB = data[(data[11]==1.0) & (data[12]==1.0) & (data[13]==1.0) & data[7]<1.0]
#data_theo_HB.to_csv(scan_file, index=False, header=False, sep=" ", mode="a")

